<template>
	<view>
		<view class="ad1">
			<view class="ad2">收件人</view>
			<input class="ad2" v-model="name" placeholder="请输入收件人姓名" />
		</view>
		<view class="ad1">
			<view class="ad2">电话号码</view>
			<input class="ad2"  v-model="tel" placeholder="请输入收件人电话号码" />
		</view>
		<view class="ad1">
			<view>地址</view>
			<view class="content">
				<view class="ad2" v-model="add1" @tap='openAddres'>{{a}}</view>
				<simple-address ref="simpleAddress" 
				:pickerValueDefault="cityPickerValueDefault" @onConfirm="onConfirm" themeColor="#007AFF">
				
				</simple-address>
			 </view>
		</view>
		<view class="ad1">
			<view class="ad2">详细地址</view>
			<input class="ad2" v-model="tag" placeholder="请输入详细地址" />
		</view>
		<view @click="bc">保存</view>
	</view>
</template>

<script>
import {save} from '../../../util/user/user.js'
import simpleAddress from '@/components/simple-address/simple-address.vue';

export default{
	data(){
		return{
			 cityPickerValueDefault: [0, 0, 1],
			 pickerText: '',
			 a:"请选择地址",
			 tag:'',
			 cityCode2:'',
			 provinceCode2:'',
			 cityStr2:'',
			 areaStr2:'',
			 tel:'',
			 region_arr2:'',
			 name:'',
			 add1:''
		}
	},
	components:{
		 simpleAddress 
	},
	methods:{
		bc(){
			save({
				userId:uni.getStorageSync('userInfo').id,
				tag:this.tag,
				cityCode:this.cityCode2,
				provinceStr:this.provinceStr2,
				cityStr:this.cityStr2,
				areaStr:this.areaStr2,
				tel:this.tel,
				name:this.name,
				isUse:0,
				region_arr:this.region_arr2
			})
			.then(res=>{
				console.log('保存成功',res)
			})
			uni.navigateTo({
				url:'./address'
			})
		},
		//获取本地用户信息
		huoqu(){
			var get=uni.getStorageSync('userInfo')
			console.log(get)
		},
		//三级导航
	    openAddres() {
			this.cityPickerValueDefault = [0,0,1]
			this.$refs.simpleAddress.open();
		},
		onConfirm(e) {
			console.log(e);
			this.a=e.label
			this.cityCode2=e.cityCode
			this.provinceStr2=e.labelArr[0]
			this.cityStr2=e.labelArr[1]
			this.areaStr2=e.labelArr[2]
			this.region_arr2=e.value.join()
			
			
			
			
		}	 
	},
	onLoad() {
		this.huoqu()
	}
}
</script>

<style>
</style>
